home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 15 code / Floating Windows / Floating Windows Code / Shell Code / trapAvail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-26  |  821 b   |  46 lines  |  [TEXT/MMCC]

  1. /*
  2.     TrapAvail — Determine the existence of a trap
  3. */
  4.  
  5. #include <Types.h>
  6. #include <Traps.h>
  7. #include <OSUtils.h>
  8.  
  9. short        NumToolboxTraps(void);
  10. TrapType    GetTrapType(short theTrap);
  11.     
  12. Boolean    TrapAvailable(short theTrap);
  13. Boolean    TrapAvailable(short theTrap)
  14. {
  15.     TrapType    tType;
  16.     Boolean        isAvail;
  17.     
  18.     tType = GetTrapType(theTrap);
  19.     if (tType == ToolTrap)
  20.         {
  21.             theTrap &= 0x07FF;
  22.             if (theTrap >= NumToolboxTraps())
  23.                 theTrap = _Unimplemented;
  24.         }
  25.     
  26.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  27.     return isAvail;
  28. }
  29.  
  30. short    NumToolboxTraps()
  31. {
  32.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  33.         return 0x0200;
  34.     else
  35.         return 0x0400;
  36. }
  37.  
  38. TrapType    GetTrapType(short theTrap)
  39. {
  40.     if ((theTrap & 0x0800) > 0)
  41.         return ToolTrap;
  42.     else
  43.         return OSTrap;
  44. }
  45.  
  46.